<?php
    use User\Model\ActivityModel;
    use User\Model\ActivityRegisterModel;
?>
<div class="row">
    <div class="col-lg-12">
        <section class="panel">
            <header class="panel-heading">
                人员详情
            </header>
            <div class="panel-body">
                <form class="form-horizontal" method="post"
                      action="<?php if($type=='add'){echo '/User/Activityjl/registerAdd';}
                      else{echo '/User/Activityjl/registerUpdate';}?>" style="width: 70%;">
                    <input type="hidden" value="<?php $val = (!empty($activityRegister)) ?
                            $activityRegister['reg_id'] : ''; echo $val;?>" name="regId">
                    <input id="actId" type="hidden" value="<?php
                            if(empty($activityRegister)){
                                echo I('get.actId', '', '');
                            }else{
                                echo $activityRegister['act_id'];
                            }?>" name="act_id">

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label need">名称:</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="name" value="<?php $val = (!empty($activityRegister)) ?
                            $activityRegister['name'] : ''; echo $val;?>">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label need">证件号:</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="card_number" value="<?php $val = (!empty($activityRegister)) ?
                            $activityRegister['card_number'] : ''; echo $val;?>">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label ">职务:</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="position" value="<?php $val=(!empty($activityRegister)) ?
                            $activityRegister['position'] : ''; echo $val;?>">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label ">称谓:</label>

                        <div class="col-sm-10">
                            <input type="radio" name="appellation" value="0" <?php if(empty($activityRegister) || (!empty($activityRegister) && $activityRegister['appellation'] == 0)){
                                echo 'checked';
                            }?>>先生
                            <input type="radio" name="appellation" value="1" <?php if(!empty($activityRegister) && $activityRegister['appellation'] == 1){
                                echo 'checked';
                            }?>>女士
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label need">公司:</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="company" value="<?php $val=(!empty($activityRegister)) ?
                            $activityRegister['company'] : ''; echo $val;?>">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label ">所属行业:</label>

                        <div class="col-sm-10">
                            <?php
                                foreach(ActivityRegisterModel::get_industry('all', 1) as $ind_key => $industry){
                            echo '<input type="radio" name="industry" value="' . $ind_key . '"';
                            if(!empty($activityRegister) && $activityRegister['industry'] == $ind_key){
                            echo " checked ";
                            }
                            echo ">" . $industry . "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
                            }
                            ?>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label ">详细地址:</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="address" value="<?php $val=(!empty($activityRegister)) ?
                            $activityRegister['address'] : ''; echo $val;?>">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label need">手机号码:</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="mobile" value="<?php $val=(!empty($activityRegister)) ?
                            $activityRegister['mobile'] : ''; echo $val;?>">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label ">备注:</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="note" value="<?php $val=(!empty($activityRegister)) ?
                            $activityRegister['note'] : ''; echo $val;?>">
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-10">
                            <button class="btn btn-primary" type="submit" id="submit">提交</button>
                            <button class="btn btn-default" type="button" onclick="history.back(-1);">取消</button>
                        </div>
                    </div>

                </form>
            </div>
        </section>
    </div>
</div>
<script>
    $(".need").each(function () {
        $(this).prepend("<span style='color:red'>*</span>");
    });
    $("#submit").click(function () {
        var data = $("form").serialize();
        var url = $("form").attr("action");
        var actId = $("#actId").val();
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            success: function (res) {
                if (res.code == 1) {
                    alert("提交成功");
                    window.location = '/User/Activityjl/register?actId=' + actId;
                } else {
                    alert(res.msg);
                }
            }
        });
        return false;
    });
</script>
<script type="text/javascript" src="/Public/js/laydate/laydate.js"></script>
<script type="text/javascript">
    $(".date-picker").bind("click", function () {
        laydate({
            format: 'YYYY/MM/DD hh:mm:ss',
            min: laydate.now(), //设定最小日期为当前日期
            max: '2099-06-16 23:59:59', //最大日期
            istime: true,
            istoday: false
        });
        laydate.skin("molv");
    });
</script>